﻿using System;
using System.IO;
using UnityEngine;

namespace Sizebox.CharacterEditor
{
	// Token: 0x02000272 RID: 626
	public class SkeletonPresetsView : BasePresetsView
	{
		// Token: 0x06000DE7 RID: 3559 RVA: 0x0006CFB8 File Offset: 0x0006B1B8
		protected override void LoadFile(string filePath)
		{
			if (File.Exists(filePath))
			{
				string json = File.ReadAllText(filePath);
				SkeletonPresetData skeletonPresetData = JsonUtility.FromJson<SkeletonPresetData>(json);
				if (skeletonPresetData == null || !skeletonPresetData.Validate())
				{
					base.OnLoadFail();
				}
				else
				{
					this.handleManager.TargetEditor.SkeletonEdit.LoadPreset(skeletonPresetData, this.handleView.DataId);
				}
			}
		}

		// Token: 0x06000DE8 RID: 3560 RVA: 0x0006D01C File Offset: 0x0006B21C
		protected override void SaveFile(string fileName)
		{
			base.EnsureFolder(this.folderPath);
			SkeletonPresetData obj = new SkeletonPresetData(this.handleView.DataId, this.handleManager.TargetEditor);
			string value = JsonUtility.ToJson(obj);
			TextWriter textWriter = new StreamWriter(string.Concat(new object[]
			{
				this.folderPath,
				Path.DirectorySeparatorChar,
				fileName,
				this.PRESET_EXTENSION
			}));
			textWriter.Write(value);
			textWriter.Close();
		}

		// Token: 0x040012D2 RID: 4818
		[Header("Skeleton References")]
		[SerializeField]
		protected BaseSkeletonHandleView handleView;
	}
}
